package p270jp.pxv.android.activity;

import android.content.ActivityNotFoundException;
import android.content.ComponentCallbacks;
import android.content.ComponentName;
import android.content.Intent;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.widget.Toast;
import androidx.lifecycle.MutableLiveData;
import java.io.Serializable;
import java.util.Objects;
import p005a5.C0022b;
import p014ae.AbstractActivityC0131o3;
import p014ae.C0146r;
import p014ae.C0180w6;
import p041ba.C1048a;
import p047bg.C1124a;
import p050bj.RoutingEvent;
import p064c6.Preconditions;
import p079cl.RoutingPresenter;
import p134ei.PixivAnalytics;
import p134ei.PremiumAnalyticsSource;
import p165fo.C3114c;
import p165fo.Subscribe;
import p183gh.ABTestService;
import p189gn.AbstractC3435a;
import p209hg.RoutingContract;
import p216hn.Lambda;
import p216hn.Reflection;
import p239ik.PushNotificationOpenEvent;
import p262jh.DeeplinkTransferService;
import p270jp.pxv.android.R;
import p270jp.pxv.android.commonObjects.model.WorkType;
import p270jp.pxv.android.event.CancelOpenUnsupportedURLEvent;
import p270jp.pxv.android.event.ConfirmOpenUnlistedWorkByBrowserEvent;
import p270jp.pxv.android.event.ConfirmOpenUserRequestsByBrowserEvent;
import p270jp.pxv.android.event.FinishUpdateLoginOrEnterNicknameEvent;
import p270jp.pxv.android.model.RoutingParameter;
import p307l9.EdgeTreatment;
import p325m0.MutabilityOwnership;
import p342mh.StartupMessageService;
import p350mp.Timber;
import p427pm.WalkThroughSettings;
import p436q6.C5768b;
import p445qf.C5830a;
import p446qh.PpointPurchaseDomainService;
import p447qi.EventPublishDialogFragment;
import p554uo.DefinitionParameters;
import p571vf.AndroidVersion;
import p579vo.Qualifier;
import p603wm.AbstractC6949c;
import p645yc.AndroidSchedulers;

/* compiled from: RoutingActivity.kt */
/* renamed from: jp.pxv.android.activity.RoutingActivity */
/* loaded from: classes2.dex */
public final class RoutingActivity extends AbstractActivityC0131o3 implements RoutingContract {

    /* renamed from: A */
    public static final /* synthetic */ int f18640A;

    /* renamed from: v */
    public RoutingPresenter f18641v;

    /* renamed from: w */
    public final AbstractC6949c f18642w = Preconditions.m9802P(1, new C4111b(this, null, null));

    /* renamed from: x */
    public final AbstractC6949c f18643x = Preconditions.m9802P(1, new C4112c(this, null, null));

    /* renamed from: y */
    public final AbstractC6949c f18644y = Preconditions.m9802P(1, new C4113d(this, null, null));

    /* renamed from: z */
    public AndroidVersion f18645z;

    /* compiled from: RoutingActivity.kt */
    /* renamed from: jp.pxv.android.activity.RoutingActivity$a */
    /* loaded from: classes2.dex */
    public static final class C4110a extends Lambda implements AbstractC3435a<DefinitionParameters> {
        /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
        public C4110a() {
            super(0);
            RoutingActivity.this = r1;
        }

        @Override // p189gn.AbstractC3435a
        public DefinitionParameters invoke() {
            return C0022b.m12183x(RoutingActivity.this);
        }
    }

    /* compiled from: ComponentCallbackExt.kt */
    /* renamed from: jp.pxv.android.activity.RoutingActivity$b */
    /* loaded from: classes2.dex */
    public static final class C4111b extends Lambda implements AbstractC3435a<DeeplinkTransferService> {

        /* renamed from: a */
        public final /* synthetic */ ComponentCallbacks f18647a;

        /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
        public C4111b(ComponentCallbacks componentCallbacks, Qualifier aVar, AbstractC3435a aVar2) {
            super(0);
            this.f18647a = componentCallbacks;
        }

        /* JADX WARN: Type inference failed for: r0v4, types: [jh.a, java.lang.Object] */
        @Override // p189gn.AbstractC3435a
        public final DeeplinkTransferService invoke() {
            return C1124a.m10173s(this.f18647a).f24118a.m920a().m621a(Reflection.m5499a(DeeplinkTransferService.class), null, null);
        }
    }

    /* compiled from: ComponentCallbackExt.kt */
    /* renamed from: jp.pxv.android.activity.RoutingActivity$c */
    /* loaded from: classes2.dex */
    public static final class C4112c extends Lambda implements AbstractC3435a<PixivAnalytics> {

        /* renamed from: a */
        public final /* synthetic */ ComponentCallbacks f18648a;

        /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
        public C4112c(ComponentCallbacks componentCallbacks, Qualifier aVar, AbstractC3435a aVar2) {
            super(0);
            this.f18648a = componentCallbacks;
        }

        /* JADX WARN: Type inference failed for: r0v4, types: [ei.e, java.lang.Object] */
        @Override // p189gn.AbstractC3435a
        public final PixivAnalytics invoke() {
            return C1124a.m10173s(this.f18648a).f24118a.m920a().m621a(Reflection.m5499a(PixivAnalytics.class), null, null);
        }
    }

    /* compiled from: ComponentCallbackExt.kt */
    /* renamed from: jp.pxv.android.activity.RoutingActivity$d */
    /* loaded from: classes2.dex */
    public static final class C4113d extends Lambda implements AbstractC3435a<ABTestService> {

        /* renamed from: a */
        public final /* synthetic */ ComponentCallbacks f18649a;

        /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
        public C4113d(ComponentCallbacks componentCallbacks, Qualifier aVar, AbstractC3435a aVar2) {
            super(0);
            this.f18649a = componentCallbacks;
        }

        /* JADX WARN: Type inference failed for: r0v4, types: [gh.a, java.lang.Object] */
        @Override // p189gn.AbstractC3435a
        public final ABTestService invoke() {
            return C1124a.m10173s(this.f18649a).f24118a.m920a().m621a(Reflection.m5499a(ABTestService.class), null, null);
        }
    }

    @Override // p209hg.RoutingContract
    /* renamed from: A0 */
    public void mo4740A0(long j) {
        WorkType workType = WorkType.NOVEL;
        MutabilityOwnership.m3745m(workType, "workType");
        Intent intent = new Intent(this, UserWorkWithoutProfileActivity.class);
        intent.putExtra("USER_ID", j);
        intent.putExtra("WORK_TYPE", workType);
        startActivity(intent);
    }

    @Override // p209hg.RoutingContract
    /* renamed from: D */
    public void mo4739D(long j) {
        startActivity(CollectionActivity.m4834e1(this, j, WorkType.ILLUST_MANGA));
    }

    @Override // p209hg.RoutingContract
    /* renamed from: G */
    public void mo4738G() {
        startActivity(new Intent(this, HomeActivity.class));
    }

    @Override // p209hg.RoutingContract
    /* renamed from: I */
    public void mo4737I() {
        overridePendingTransition(0, R.anim.fade_out_routing);
        finish();
    }

    @Override // p209hg.RoutingContract
    /* renamed from: P */
    public void mo4736P(String str) {
        MutabilityOwnership.m3745m(str, "transferUrl");
        EventPublishDialogFragment.C5840a aVar = EventPublishDialogFragment.f25435a;
        String string = getString(R.string.deeplink_transfer_unlisted_url, new Object[]{str});
        String string2 = getString(R.string.common_ok);
        MutabilityOwnership.m3746l(string2, "getString(jp.pxv.android…egacy.R.string.common_ok)");
        aVar.m2777b(string, string2, getString(R.string.common_cancel), new ConfirmOpenUnlistedWorkByBrowserEvent(str), new CancelOpenUnsupportedURLEvent(), null, false).show(m11131K0(), "showYesNoDialog");
    }

    /* renamed from: S0 */
    public final PixivAnalytics m4735S0() {
        return (PixivAnalytics) this.f18643x.getValue();
    }

    @Override // p209hg.RoutingContract
    /* renamed from: T */
    public void mo4734T(long j) {
        WorkType workType = WorkType.ILLUST;
        MutabilityOwnership.m3745m(workType, "workType");
        Intent intent = new Intent(this, UserWorkWithoutProfileActivity.class);
        intent.putExtra("USER_ID", j);
        intent.putExtra("WORK_TYPE", workType);
        startActivity(intent);
    }

    /* renamed from: T0 */
    public final void m4733T0(String str) {
        if (this.f18645z != null) {
            if (24 <= Build.VERSION.SDK_INT) {
                startActivity(((DeeplinkTransferService) this.f18642w.getValue()).m4878b(str, new ComponentName[]{new ComponentName(this, IntentFilterActivity.class.getName())}));
            } else {
                startActivity(((DeeplinkTransferService) this.f18642w.getValue()).m4879a(str));
            }
        } else {
            MutabilityOwnership.m3737u("androidVersion");
            throw null;
        }
    }

    @Override // p209hg.RoutingContract
    /* renamed from: U */
    public void mo4732U(long j) {
        Intent intent;
        if (((ABTestService) this.f18644y.getValue()).m5838a()) {
            intent = new Intent(this, NovelTextActivity.class);
            intent.putExtra("NOVEL_ID", j);
            intent.putExtra("PREVIOUS_SCREEN", (Serializable) null);
        } else {
            intent = NovelDetailActivity.m4804e1(this, j);
        }
        startActivity(intent);
    }

    @Override // p209hg.RoutingContract
    /* renamed from: g */
    public void mo4731g(long j) {
        WorkType workType = WorkType.MANGA;
        MutabilityOwnership.m3745m(workType, "workType");
        Intent intent = new Intent(this, UserWorkWithoutProfileActivity.class);
        intent.putExtra("USER_ID", j);
        intent.putExtra("WORK_TYPE", workType);
        startActivity(intent);
    }

    @Override // p209hg.RoutingContract
    /* renamed from: g0 */
    public void mo4730g0() {
        startActivity(LoginOrEnterNickNameActivity.m4814S0(this));
    }

    @Override // p209hg.RoutingContract
    /* renamed from: h */
    public void mo4729h(long j) {
        startActivity(IllustDetailSingleActivity.m4818j1(this, j));
    }

    @Override // p209hg.RoutingContract
    /* renamed from: h0 */
    public void mo4728h0(long j) {
        startActivity(FollowUserActivity.m4827e1(this, j));
    }

    @Override // p209hg.RoutingContract
    /* renamed from: o */
    public void mo4727o() {
        startActivity(new Intent(this, NewWorksActivity.class));
    }

    @Override // androidx.fragment.app.FragmentActivity, androidx.activity.ComponentActivity, p248j2.ActivityC3902g, android.app.Activity
    public void onCreate(Bundle bundle) {
        super.onCreate(bundle);
        setContentView(R.layout.activity_routing);
        C3114c.m6284b().m6276j(this);
        m11131K0().m11251d0("fragment_request_key_charcoal_dialog_fragment", this, new C5768b(this, 13));
        RoutingPresenter iVar = new RoutingPresenter(this, (PpointPurchaseDomainService) C1124a.m10173s(this).f24118a.m920a().m621a(Reflection.m5499a(PpointPurchaseDomainService.class), null, new C4110a()), m4735S0(), (StartupMessageService) C1124a.m10173s(this).f24118a.m920a().m621a(Reflection.m5499a(StartupMessageService.class), null, null), (WalkThroughSettings) C1124a.m10173s(this).f24118a.m920a().m621a(Reflection.m5499a(WalkThroughSettings.class), null, null));
        this.f18641v = iVar;
        Intent intent = getIntent();
        Objects.requireNonNull(iVar);
        if (intent.hasExtra("FROM_NOTIFICATION_MESSAGE")) {
            iVar.f5555a.m6526d(new PushNotificationOpenEvent(intent.getStringExtra("TYPE"), intent.getStringExtra("TITLE"), intent.getStringExtra("FROM_NOTIFICATION_MESSAGE"), intent.getStringExtra("TARGET_URL")));
        }
        if (intent.hasExtra("TARGET_URL")) {
            iVar.f5563i = intent.getStringExtra("TARGET_URL");
        }
        if (intent.hasExtra("ROUTING")) {
            iVar.f5559e = (RoutingParameter) intent.getSerializableExtra("ROUTING");
        }
        StartupMessageService cVar = iVar.f5560f;
        iVar.f5558d.mo82c(cVar.f23030a.mo7229a().m970f(new C1048a(cVar, 12)).m966j(AndroidSchedulers.m334a()).m963m(new C0180w6(iVar, 11), new C0146r(iVar, 15)));
        RoutingPresenter iVar2 = this.f18641v;
        if (iVar2 != null) {
            MutableLiveData<C5830a<RoutingEvent>> xVar = iVar2.f5564j;
            MutabilityOwnership.m3746l(xVar, "routingPresenter.event");
            Preconditions.m9798T(xVar, this, new p014ae.RoutingActivity(this));
            return;
        }
        MutabilityOwnership.m3737u("routingPresenter");
        throw null;
    }

    @Override // p116e.ActivityC2727f, androidx.fragment.app.FragmentActivity, android.app.Activity
    public void onDestroy() {
        RoutingPresenter iVar = this.f18641v;
        if (iVar != null) {
            iVar.onDestroy();
            C3114c.m6284b().m6274l(this);
            super.onDestroy();
            return;
        }
        MutabilityOwnership.m3737u("routingPresenter");
        throw null;
    }

    @Subscribe
    public final void onEvent(FinishUpdateLoginOrEnterNicknameEvent finishUpdateLoginOrEnterNicknameEvent) {
        MutabilityOwnership.m3745m(finishUpdateLoginOrEnterNicknameEvent, "event");
        RoutingPresenter iVar = this.f18641v;
        if (iVar != null) {
            iVar.m9722j();
        } else {
            MutabilityOwnership.m3737u("routingPresenter");
            throw null;
        }
    }

    @Override // p209hg.RoutingContract
    /* renamed from: r */
    public void mo4726r() {
        startActivity(PremiumActivity.m4769V0(this, PremiumAnalyticsSource.URL_SCHEME));
    }

    @Override // p209hg.RoutingContract
    /* renamed from: r0 */
    public void mo4725r0(long j) {
        startActivity(CollectionActivity.m4834e1(this, j, WorkType.NOVEL));
    }

    @Override // p209hg.RoutingContract
    /* renamed from: u0 */
    public void mo4724u0() {
        startActivity(new Intent(this, WalkThroughActivity.class));
    }

    @Override // p209hg.RoutingContract
    /* renamed from: v */
    public void mo4723v(long j) {
        EdgeTreatment.m3910h(j > 0);
        Intent intent = new Intent(this, UserProfileActivity.class);
        intent.putExtra("USER_ID", j);
        startActivity(intent);
    }

    @Override // p209hg.RoutingContract
    /* renamed from: x */
    public void mo4722x(String str) {
        MutabilityOwnership.m3745m(str, "targetUrl");
        Intent intent = new Intent();
        intent.setAction("android.intent.action.VIEW");
        intent.setData(Uri.parse(str));
        startActivity(intent);
    }

    @Override // p209hg.RoutingContract
    /* renamed from: x0 */
    public void mo4721x0(String str) {
        MutabilityOwnership.m3745m(str, "transferUrl");
        EventPublishDialogFragment.C5840a aVar = EventPublishDialogFragment.f25435a;
        String string = getString(R.string.deeplink_transfer_request_feature, new Object[]{str});
        String string2 = getString(R.string.common_ok);
        MutabilityOwnership.m3746l(string2, "getString(jp.pxv.android…egacy.R.string.common_ok)");
        aVar.m2777b(string, string2, getString(R.string.common_cancel), new ConfirmOpenUserRequestsByBrowserEvent(str), new CancelOpenUnsupportedURLEvent(), null, false).show(m11131K0(), "showYesNoDialog");
    }

    @Override // p209hg.RoutingContract
    /* renamed from: y */
    public void mo4720y() {
        startActivity(new Intent(this, SearchTopActivity.class));
    }

    @Subscribe
    public final void onEvent(ConfirmOpenUnlistedWorkByBrowserEvent confirmOpenUnlistedWorkByBrowserEvent) {
        MutabilityOwnership.m3745m(confirmOpenUnlistedWorkByBrowserEvent, "event");
        try {
            m4733T0(confirmOpenUnlistedWorkByBrowserEvent.getTransferUrl());
        } catch (ActivityNotFoundException e) {
            Timber.f23100a.mo3513q(e, "限定公開のURLを開ける他のアプリが存在しない: %s", confirmOpenUnlistedWorkByBrowserEvent.getTransferUrl());
            Toast.makeText(this, getString(R.string.browser_not_found), 0).show();
        } catch (Throwable th) {
            Timber.f23100a.mo3513q(th, "限定公開のURLが他のアプリで開けなかった: %s", confirmOpenUnlistedWorkByBrowserEvent.getTransferUrl());
            Toast.makeText(this, getString(R.string.error_default_message), 0).show();
        }
        mo4737I();
    }

    @Subscribe
    public final void onEvent(ConfirmOpenUserRequestsByBrowserEvent confirmOpenUserRequestsByBrowserEvent) {
        MutabilityOwnership.m3745m(confirmOpenUserRequestsByBrowserEvent, "event");
        try {
            m4733T0(confirmOpenUserRequestsByBrowserEvent.getTransferUrl());
        } catch (ActivityNotFoundException e) {
            Timber.f23100a.mo3513q(e, "リクエスト受付URLを開ける他のアプリが存在しない: %s", confirmOpenUserRequestsByBrowserEvent.getTransferUrl());
            Toast.makeText(this, getString(R.string.browser_not_found), 0).show();
        } catch (Throwable th) {
            Timber.f23100a.mo3513q(th, "リクエスト受付URLが他のアプリで開けなかった: %s", confirmOpenUserRequestsByBrowserEvent.getTransferUrl());
            Toast.makeText(this, getString(R.string.error_default_message), 0).show();
        }
        mo4737I();
    }

    @Subscribe
    public final void onEvent(CancelOpenUnsupportedURLEvent cancelOpenUnsupportedURLEvent) {
        MutabilityOwnership.m3745m(cancelOpenUnsupportedURLEvent, "event");
        mo4737I();
    }
}
